###APPENDIX B

#####Class: All classes per issue dimension  (among potentials)
hlines_values2 <- c(15, 11, 8, 4) 

mm4 <- cj(df1, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
            Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~oesch)

#Plot
cj_class2<-plot(mm4,group = "oesch", vline = 0.5, size=3) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.38, 0.62), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        15) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Class")) + theme(legend.position="bottom") +  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x))) +
  theme(axis.text.y = element_text(face = c('plain', 'plain', 'plain', 'bold',
                                            'plain', 'plain', 'plain', 'bold',
                                            'plain', 'plain','bold',
                                            'plain', 'plain', 'plain','bold')))

#Only cultural issues
cj_class2$data <- cj_class2$data[c(1:15, 34:48, 67:81, 100:114, 133:147, 166:180, 199:213, 232:246),]
cj_class_2 <- cj_class2 + geom_hline(yintercept = hlines_values2, color = "black", linetype = "dashed") 


#Only economic issues
cj_class_3 <- cj_class + geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))   

cj_class_3$data <- cj_class_3$data[c(16:33, 49:66, 82:99, 115:132, 148:165, 181:198, 214:231, 247:264),]



#mm for union  (among potentials)
mm_union <- cj(df1, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                 Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~union)

#Plot
cj_union <-plot(mm_union,group = "union", vline = 0.5, size=3) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.4, 0.6), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        15) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Union Member")) + theme(legend.position="bottom")  +
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) 



#mm for sex  (among potentials)
mm_sex <- cj(df1, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
               Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~sex)

#Plot
cj_sex<-plot(mm_sex,group = "sex", vline = 0.5, size=3) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.4, 0.6), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        15) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Gender")) + theme(legend.position="bottom")   +
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) 




#Sociodemographic Analyses
#mm for urbanrural  (among potentials)
mm_urbanrural <- cj(df1, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                      Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~urban)

#Plot
cj_urban <-plot(mm_urbanrural,group = "urban", vline = 0.5, size=3) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.4, 0.6), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        15) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Urban")) + theme(legend.position="bottom")  +
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) 



#marginal means Income  (among potentials)
mm_inc <- cj(df1, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
               Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~inc)

#Plot
cj_inc<-plot(mm_inc,group = "inc", vline = 0.5, size=3) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.4, 0.6), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        15) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Income Groups")) + theme(legend.position="bottom") +  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x))) +
  theme(text=element_text(face = c('plain', 'plain','plain','bold', 'plain', 'plain','bold', 'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) + geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") 



#marginal means voters vs. non voters (among potentials)
mm_voters <- cj(df1, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                  Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~vote_sd)

#Plot
cj_voters_SD<-plot(mm_voters,group = "vote_sd", vline = 0.5, size=5) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.4, 0.6), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        20) + theme(text=element_text(family="Garamond", size=22)) +
  guides(color=guide_legend("Social Democratic Voters")) + theme(legend.position="bottom") + 
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold')))+ 
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))

